#include "../../server/server.hpp"
#include "../../common/detail.hpp"

void Add(const Json::Value &params, Json::Value &result)
{
    int num1 = params["num1"].asInt();
    int num2 = params["num2"].asInt();

    result = num1 + num2;
}
int main()
{
   std::unique_ptr<qiangsir::server::ServiceDescribeFactor> ser_desc(new qiangsir::server::ServiceDescribeFactor());
   ser_desc->setMethodName("Add");
   ser_desc->setParamsDesc("num1",qiangsir::server::param_type::INTEGRAL);
   ser_desc->setParamsDesc("num2",qiangsir::server::param_type::INTEGRAL);
   ser_desc->setCallback(Add);
   ser_desc->setReturnType(qiangsir::server::param_type::INTEGRAL);

   qiangsir::server::RpcServer server(qiangsir::Address("127.0.0.1",8888),true,qiangsir::Address("127.0.0.1",8080));
   server.registerService(ser_desc->build());
   server.start();
}
